package com.zsrt.java.day20161226.wrl.day161226.demo12;

public class ArrayUtil {
	/*public static void main(String[] args) {
		int[] ages = new int[3];
		ages[0] = 23;
		ages[1] = 18;
		ages[2] = 16;
		printArray(ages);
	}*/

	/**
	 * 顺序遍历数组元素
	 * @param arrays	数组
	 */
	public static void printArray(int[] arrays) {
		int len = arrays.length;
		for (int index = 0; index <= len - 1; index++) {
			int value = arrays[index];
			if (index == len - 1) {
				System.out.print(value);
				break;
			}
			System.out.print(value + " , ");
		}
	}
	
	/**
	 * 反向遍历数组元素
	 * @param arrays	数组
	 */
	public static void printReverseArray(int[] arrays) {
		int len = arrays.length;
		for (int index = len-1; index >= 0; index--) {
			int value = arrays[index];
			if (index == 0) {
				System.out.print(value);
			} else {
				System.out.print(value + " , ");
			}
		}
	}
}
